﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using PolePositionMobileUtilityGeneral;

namespace PolePositionMobileUtilityApplication
{
    public partial class FrmAbout : frmBase
    {
        public FrmAbout()
        {
            InitializeComponent();
        }

        private void FrmAbout_Load(object sender, EventArgs e)
        {
            long _FreeBytesAvailable = 0;
            long _TotalNumberOfBytes = 0;
            long _TotalNumberOfFreeBytes = 0;
            double _TotalNumberOfBytesMB;
            double _TotalNumberOfFreeBytesMB;

            #region Config form
            lblTitle.Text = "PPI | About";
            SetLButton("OK");
            #endregion

            lblMessage.Text = "";
            lblMessage.Text += "Pole Position Mobile Version 1.0\n";
            GetDiskFreeSpaceEx(PPIConstants.K_SDCardPath, ref _FreeBytesAvailable, ref _TotalNumberOfBytes, ref _TotalNumberOfFreeBytes);
            _TotalNumberOfBytesMB = Convert.ToDouble(_TotalNumberOfBytes) / 1024 / 1024;
            _TotalNumberOfFreeBytesMB = Convert.ToDouble(_TotalNumberOfFreeBytes) / 1024 / 1024;
            lblMessage.Text += "Total disk space: " + (_TotalNumberOfBytesMB / 1024 < 1 ? _TotalNumberOfBytesMB.ToString("F") + "MB" : (_TotalNumberOfBytesMB / 1024).ToString("F") + "GB") + "\n";
            lblMessage.Text += "Free disk space: " + (_TotalNumberOfFreeBytesMB / 1024 < 1 ? _TotalNumberOfFreeBytesMB.ToString("F") + "MB" : (_TotalNumberOfFreeBytesMB / 1024).ToString("F") + "GB") + " (" + Convert.ToInt32(_TotalNumberOfFreeBytes * 100 / _TotalNumberOfBytes).ToString() + "%)\n";
            lblMessage.Text += "Battery level: " + GetEnergyPercentage(m_Handheld.BatteryLevel).ToString("F2") + "%\n";
            if (m_GPS != null)
                lblMessage.Text += "Satellite(s) connected: " + m_GPS.NmeaGGA.SateliteCount + "\n";
        }

        protected override void lblLButton_Click(object sender, EventArgs e)
        {
            this.Close();
        }
        protected override void lblClose_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}